State Estimation in Linear and Non-Linear Systems
in reference to Chemical Engineering
Submitted in partial fulfillment of the requirements of the degree of
Bachelor of Technology
by :
Mayank Sanjay Kumar Gupta - 211916
Wakde Vaibhav Mohanrao - 211927
Supervisor :
Dr. Venkata Goutham Polisetty
Department of Chemical Engineering
NATIONAL INSTITUTE OF TECHNOLOGY ANDHRA PRADESH
2022-2023
Table of Contents
Sr.no
Title
Page Number
1
Introduction
1
2
Review of Literature
3
3
Report on the Present Investigation
4
3.1
Theoretical and Mathematical Derivation
4
3.1.1
Bayes Filter
4
3.1.2
Kalman Filter
5
4
Results and Discussion
7
5
Summary and Conclusions
9
6
Appendix
10
6.1
Appendix-1
10
6.2
Appendix-2
12
7
Literature Cited
15
Chapter 1
Introduction
Kalman Filter is a linear quadratic estimation (LQE) algorithm ,which utilizes a series of
measurements over interval of time , along with the statistical noises , to estimate the value of a
variable .We do not obtain accurate results with single set of measurements hence Kalman Filter
(KF) makes use of a joint probability distribution over the variables for each timeframe.
Kalman Filter has wide applications as it is an optimal estimator , but it is valid under
certain assumptions -
Errors have a normal (Gaussian) distribution.
Physical random phenomena due to primary random sources exciting dynamic
systems.Physical random phenomena may be thought of as due to primary random
sources exciting dynamic systems
The primary sources are assumed to be independent gaussian random processes with zero
mean; the dynamic systems will be linear. [1]
Kalman Filter is a linear estimator but it may be extended to non linear systems by means
of - EKF (Extended Kalman Filter) and
UKF (Unscented Kalman Filter) .Kalman
Filter is based on Markov's model.KF can
be understood by help of Figure-1.1- [1]
and has Prediction and updation step.
Figure-1.1 - Kalman Filter
Kalman filtering has numerous technological applications. A common application is for
guidance, navigation, and control of vehicles, particularly aircraft, spacecraft and ships
positioned dynamically.
Through this project we aim to estimate the state of linear and nonlinear systems with
respect to chemical engineering .In the initial part of the project we go over the theoretical and
mathematical conceptualization of the Kalman Filter .
Then we try to model and simulate the given example with the help of a Python
code. Similarly KF can be applied to a CSTR to estimate the parameters such as concentration or
pressure.The non linear filters may be used for real-time implementable optimization of the Fuel
Efficiency of Solid Oxide Fuel Cells.
2
Chapter 2
Review of Literature
Kalman Filter has been an area of research for several decades and various papers have
been published on it. While working on this project we referred to - Constrained Nonlinear State
Estimation Using Ensemble Kalman Filters [2] and Constrained nonlinear state estimation based
on the UKF approach [3] .
The key takeaways from the first paper [2] were :
Proposed a constrained recursive formulation of the ensemble Kalman filter (EnKF) that
retains the advantages of unconstrained EnKF while systematically dealing with bounds
on the estimated state variables.
The performance of the proposed constrained EnKF is compared with the performances
obtained using the recursive constrained formulations available in the literature using two
benchmark examples from the literature (a gas-phase reactor and an isothermal batch
reactor), which involve constraints on the estimated state variables.
When compared, the performance of the proposed C-EnKF formulation was found to be
significantly better than those obtained using RNDDR and C-UKF formulations.
Furthermore, the performance of the proposed C-EnKF scheme was found to be
satisfactory when employed for state estimation in a system having constraints on process
noise.
The key takeaways from the second paper [3] were :
Overview of several UKF based nonlinear estimation algorithms as an alternative to the
EKF
Suggested a reformulation of the correction step which can be applied to all of the
presented UKF algorithms, presented a QP formulation of the NLP UKF (which also can
be applied to all of the presented UKF algorithms)
Proposed alternatives to realize constraints within the UKF approach
3
Chapter 3
Report on the Present Investigation
3.1 Theoretical and Mathematical Derivation
3.1.1 Bayes Filter
The Kalman Filter is based on the Bayes theorem and Markov Assumption. From the
Bayes theorem we get the following equation :
The above equation shows the probability of event A
1
occuring when the event B has
occurred.The above result then may be extended to multiple events whose detailed derivation has
been given in Appendix-1.
On the other hand the Markov Assumption may be understood using Figure 3.1
Here
We see that at time t-1 when we give
input U then we get state X at t-1 and its
measurement Z at time t-1 .Similarly at time t
we give input and obtain the state X at time t
whose measurement is Z
t .
Figure 3.1 - Markov Assumption
4
Thus on observing the pattern we see that state X at time t depends upon state X at time t-1 and
input U at time t while the measurement at time t depends on the state X at time t only
.Mathematically it may be represented as :
The final formulation of the Bayes filter is obtained by the combination of the Bayes
theorem and Markov's assumption which is described in detail in Appendix-1.
The final equation obtained is :
From this we observe that Posterior of State = Likelihood of state * (Previous Estimation)
Kalman Filter is for linear systems where - the state
X and the measurement Z can be represented
linearly as-
( w in Z denotes the error in measurement)
3.1.2 Kalman Filter
If we were to track the position and velocity of a moving object then the state may be
written as-
While using one dimensional equation the state and new covariance matrix may be represented
as-
5
Here B represents the command matrix whereas Q represents the process noise matrix and the
above equation also represents the Prediction step in KF.
Heading on to the Updation step we take the results from measuring devices like
sensors and model them and finally combine with the prediction results by making use of
gaussian multiplication to obtain the final best estimate as :
Here K represents the gain obtained during the gaussian multiplication.The detailed
Mathematical derivation is present in Appendix-2.
6
Chapter 4
Results and Discussion
Finally the example of a moving body was modeled in Python Code.
The Python Code [4] was referred to and was formulated as :
Initial state of system was taken in Gaussian form as
Figure-4.1- Initial State
Then an error of given range was introduced shown by the graph-
Figure-4.2 - Error introduced
Next the predicted and measured values were obtained.
Then gaussian multiplication was carried out to obtained the optimum result represented
by the dotted lines in the figure-
7
Figure-4.3-Predicted , Measured and Optimum state
Then the results were observed when the belief or K (gain) was varied
Figure-4.4- Variation of the Optimum value as Gain K is changed.
Thus from the above obtained graphs we may conclude that the optimum result varies
with the Predicted and the Measured value and the gain k which represent the trust or
certainty we have in either of the values .
We also see that the variance of optimum result is lesser ( higher precision) than
both the predicted and measured value from figure-4.3.
From figure 4.4 we see that if we have higher certainty in one value be it Predicted or
measured , the optimum graph lies closer to the value having higher certainty.
8
Chapter 5
Summary and Conclusions
The initial phase began with introduction to the Kalman Filters and their applications
.From there the literature reviews were discussed along with the key takeaways from the
respective papers.
Further the important theoretical concepts and important Mathematical equations
were discussed while finally heading over to the results obtained by the code.
From the above we may conclude that Kalman Filter is an Optimal Estimator for
Linear systems .
9
Chapter 6
Appendix
6.1 Appendix-1
Derivation of Bayes Filter using Bayes theorem and Markov’s Assumptions:
Probability of area shown in figure 6.1 can be represented as
Figure-6.1
On extending the result -
10
Now on combining the above result and Markov Assumption we will get-
11
6.2 Appendix-2
The linear state may be represented as-
Figure-6.2- state multiplied by a scalar K
Now on modeling the belief as a Gaussian distribution-
12
Figure-6.3-represents gaussian multiplication
13
6.2.1 Prediction Step
6.2.2 Updation Step
‘Thus the final optimum equation obtained is-
14
Chapter 7
Literature Cited
1. Kalman filter
https://en.wikipedia.org/wiki/Kalman_filter
2. Constrained Nonlinear State Estimation Using Ensemble Kalman Filters
J. Prakash, Sachin C. Patwardhan, and Sirish L. Shah
Industrial & Engineering Chemistry Research 2010 49 (5), 2242-2253
DOI: 10.1021/ie900197s
3. S. Kolås, B.A. Foss, T.S. Schei,
Constrained nonlinear state estimation based on the UKF approach,
Computers & Chemical Engineering,
Volume 33, Issue 8,2009,
ISSN 0098-1354,
https://doi.org/10.1016/j.compchemeng.2009.01.012.
4.GitHub - rlabbe/Kalman-and-Bayesian-Filters-in-Python
https://github.com/rlabbe/Kalman-and-Bayesian-Filters-in-Python
15